package com.spareparts.protocol;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.spareparts.entyties.WareHouse;

import cm.framework.protocol.BaseJSONRsponse;

public class WarehouseByQuYuResponse extends BaseJSONRsponse 
{
	public List<WareHouse> mWareHouseList = new ArrayList<WareHouse>();
	
	@Override
	protected boolean extractBody(JSONObject arg0) 
	{
		try 
		{
			JSONArray dataJsonArray = arg0.getJSONArray("res");
			if ( dataJsonArray != null && dataJsonArray.length()>0)
			{
				WareHouse oWareHouse1 = new WareHouse();
				oWareHouse1.wid = "";
				oWareHouse1.wName = "";
				mWareHouseList.add(oWareHouse1);
				for(int i=0;i<dataJsonArray.length();i++)
				{
					WareHouse oWareHouse = new WareHouse();
					JSONObject jsonObj = dataJsonArray.getJSONObject(i);
					oWareHouse.wid = jsonObj.getString("id");
					oWareHouse.wName = jsonObj.getString("name");
					mWareHouseList.add(oWareHouse);
				}
			}
		}
		catch (JSONException e)
		{
			e.printStackTrace();
		}
		return true;
	}

}
